test: expand main-process unit coverage#965
Closed
notluquis wants to merge 7 commits into
Closed
Conversation
EnvironmentTypeName mapping plus IEventTypeMain/Renderer registry shape. Note: AI-assisted (Claude Code). Manually verified: 2-dot import paths, vitest green, no tautological asserts (enum-completeness loop pairs toBeDefined with a typeof string check).
Path/home resolution, port checks, env path builders, wait helpers. Note: AI-assisted (Claude Code). Manually verified: rewrote getRelativePathToUserHome from a typeof-function tautology to a behavioral assertion, mutation check (return absolutePath instead of the ~ form) fails the test and restoring passes.
Default values, setValue overrides, persisted application data shape. Note: AI-assisted (Claude Code). Manually verified: 2-dot paths, removed unused imports, made the workspace override test assert the pre-override default differs from the new value, vitest green.
Remote vs local sessions, working dir resolution, python path inclusion. Note: AI-assisted (Claude Code). Manually verified: 2-dot paths, the toBeDefined matchers are each paired with concrete assertions on isRemote/remoteURL/pythonPath, vitest green.
parseCLIArgs subcommands and the env list/handler paths. Note: AI-assisted (Claude Code). Manually verified: switching to 2-dot paths made the appdata mock actually apply, which exposed a stale mock field (discoveredPythonPaths vs discoveredPythonEnvs); fixed the mock to match the real shape, vitest green.
Sync and async handler registration, dispose unregistering all handlers. Restore ipcMain.removeListener on the electron mock; eventmanager.ts uses it in unregisterAllEventHandlers and the mock had dropped it. Note: AI-assisted (Claude Code). Manually verified: dispose tests failed with "removeListener is not a function" until the mock was restored, then 305/305 green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second of the Phase 2 PRs from the plan in #951, building on the test infra merged in #961.
Adds unit coverage for the main process: tokens, event types, utils, settings, workspace settings, appdata, sessionconfig, cli + cli handlers, and the EventManager. Commits are split by area so each can be reviewed on its own. No application code in
src/main/orsrc/browser/changes here, only tests plus one mock fix.A couple of things worth flagging from writing these:
test/unit(../../src/main/...). While converting from an earlier 3-dot version I noticed the 3-dot paths were silently not applying thevi.mockfactories, so some tests were exercising the real modules instead of the mocks. Fixing the paths surfaced a stale mock field in the cli test (discoveredPythonPathsvs the realdiscoveredPythonEnvs), now corrected.eventmanager.tscallsipcMain.removeListenerinunregisterAllEventHandlers, but the shared electron mock had dropped that method, so the dispose tests failed until it was restored.getRelativePathToUserHometest was atypeof === 'function'tautology; rewrote it to assert the actual~-prefixed output, and confirmed with a mutation (returning the raw path fails the test).Local verification:
yarn test:unit305/305,npx tsc --noEmitexit 0, prettier and eslint clean ontest/.Husky/lint-staged and the cross-platform CI work follow in a later PR.
Note: AI-assisted (Claude Code). Manually verified: the 2-dot path / mock behavior above, the EventManager removeListener failure and fix, and the getRelativePathToUserHome mutation check, all run locally on macOS.